/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.bar.carta.model;

import com.bar.carta.service.PlatoIdiomaLocalServiceUtil;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.impl.BaseModelImpl;

import java.io.Serializable;

import java.lang.reflect.Proxy;

/**
 * @author pgonzalm
 */
public class PlatoIdiomaClp extends BaseModelImpl<PlatoIdioma>
	implements PlatoIdioma {
	public PlatoIdiomaClp() {
	}

	public Class<?> getModelClass() {
		return PlatoIdioma.class;
	}

	public String getModelClassName() {
		return PlatoIdioma.class.getName();
	}

	public long getPrimaryKey() {
		return _platoIdiomaId;
	}

	public void setPrimaryKey(long primaryKey) {
		setPlatoIdiomaId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_platoIdiomaId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public long getPlatoIdiomaId() {
		return _platoIdiomaId;
	}

	public void setPlatoIdiomaId(long platoIdiomaId) {
		_platoIdiomaId = platoIdiomaId;
	}

	public long getPlatoId() {
		return _platoId;
	}

	public void setPlatoId(long platoId) {
		_platoId = platoId;
	}

	public String getName() {
		return _name;
	}

	public void setName(String name) {
		_name = name;
	}

	public String getDescripcion() {
		return _descripcion;
	}

	public void setDescripcion(String descripcion) {
		_descripcion = descripcion;
	}

	public int getIdioma() {
		return _idioma;
	}

	public void setIdioma(int idioma) {
		_idioma = idioma;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			PlatoIdiomaLocalServiceUtil.addPlatoIdioma(this);
		}
		else {
			PlatoIdiomaLocalServiceUtil.updatePlatoIdioma(this);
		}
	}

	@Override
	public PlatoIdioma toEscapedModel() {
		return (PlatoIdioma)Proxy.newProxyInstance(PlatoIdioma.class.getClassLoader(),
			new Class[] { PlatoIdioma.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		PlatoIdiomaClp clone = new PlatoIdiomaClp();

		clone.setPlatoIdiomaId(getPlatoIdiomaId());
		clone.setPlatoId(getPlatoId());
		clone.setName(getName());
		clone.setDescripcion(getDescripcion());
		clone.setIdioma(getIdioma());

		return clone;
	}

	public int compareTo(PlatoIdioma platoIdioma) {
		long primaryKey = platoIdioma.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		PlatoIdiomaClp platoIdioma = null;

		try {
			platoIdioma = (PlatoIdiomaClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = platoIdioma.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(11);

		sb.append("{platoIdiomaId=");
		sb.append(getPlatoIdiomaId());
		sb.append(", platoId=");
		sb.append(getPlatoId());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", descripcion=");
		sb.append(getDescripcion());
		sb.append(", idioma=");
		sb.append(getIdioma());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(19);

		sb.append("<model><model-name>");
		sb.append("com.bar.carta.model.PlatoIdioma");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>platoIdiomaId</column-name><column-value><![CDATA[");
		sb.append(getPlatoIdiomaId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>platoId</column-name><column-value><![CDATA[");
		sb.append(getPlatoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>descripcion</column-name><column-value><![CDATA[");
		sb.append(getDescripcion());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>idioma</column-name><column-value><![CDATA[");
		sb.append(getIdioma());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _platoIdiomaId;
	private long _platoId;
	private String _name;
	private String _descripcion;
	private int _idioma;
}